package com.shanzmoo.platform.manage.api.web.merchant;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.db.module.merchant.domain.dto.MerchantOrderInfoDto;
import com.shanzmoo.db.module.merchant.domain.dto.MerchantOrderRefundDto;
import com.shanzmoo.db.module.merchant.domain.query.MerchantOrderQuery;
import com.shanzmoo.db.module.merchant.domain.vo.MerchantOrderVo;
import com.shanzmoo.platform.manage.api.manager.merchant.MerchantOrderManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 支付订单管理控制器
 * @author fs
 */
@Slf4j
@Api(tags = "订单管理")
@RestController
@RequestMapping("/merchant-order")
@RequiredArgsConstructor
public class MerchantOrderController {
    private final MerchantOrderManager merchantOrderManager;
    @ApiOperation(value = "订单分页")
    @PostMapping("/page-list")
    public SHttpResponse<IPage<MerchantOrderVo>> pageList(@RequestBody MerchantOrderQuery query) {
        return SHttpResponse.ok(merchantOrderManager.pageList(query));
    }

    @ApiOperation(value = "订单退款")
    @PostMapping("/refund")
    public SHttpResponse<IPage<MerchantOrderVo>> refund(@RequestBody MerchantOrderRefundDto refundDto) {
        merchantOrderManager.refund(refundDto);
        return SHttpResponse.ok();
    }

    @ApiOperation(value = "订单详情")
    @PostMapping("/info")
    public SHttpResponse<MerchantOrderVo> info(@RequestBody MerchantOrderInfoDto infoDto) {
        return SHttpResponse.ok(merchantOrderManager.info(infoDto));
    }
}
